From a33793ae44cf733c6562b4b366a7e26e299d0622 Mon Sep 17 00:00:00 2001 From: "tw275@labyrinth.cl.cam.ac.uk" Date: Mon, 26 Jul 2004 12:57:47 +0000 Subject: [PATCH] bitkeeper revision 1.1108.1.21 (4104ffcb0fLoE7HIdNvUGJI49n_Sxg) Added menu writing, improving the menu on the left of the page, and gerneralized getDomInfoHash, should work with upgraded versions of xend --- .rootkeys | 2 ++ tools/python/xen/sv/DomInfo.py | 33 +++++++++++++++++++--- tools/python/xen/sv/DomList.py | 11 ++++---- tools/python/xen/sv/Main.py | 9 +++--- tools/python/xen/sv/NodeInfo.py | 3 ++ tools/python/xen/sv/util.py | 47 +++++++++++++++++++------------- tools/sv/Makefile | 2 ++ tools/sv/images/pause.png | Bin 0 -> 1662 bytes tools/sv/images/unpause.png | Bin 0 -> 1890 bytes 9 files changed, 73 insertions(+), 34 deletions(-) create mode 100644 tools/sv/images/pause.png create mode 100644 tools/sv/images/unpause.png diff --git a/.rootkeys b/.rootkeys index 053bb5cede..b888478532 100644 --- a/.rootkeys +++ b/.rootkeys @@ -442,6 +442,7 @@ 40fcefb38OTgsUKHBpwshLLIsiIaCA tools/sv/images/middle-no-highlight.jpg 40fcefb32SPtrw36c4S6YGFlLvkKuw tools/sv/images/orb_01.jpg 40fcefb3Ok5qkX3iM7ZEPVkRInrUpg tools/sv/images/orb_02.jpg +4104ffca9_GhWOxRE-83uZIad2Z1gg tools/sv/images/pause.png 41013a82ILk71xLqWFH5ZO5VmOIvBw tools/sv/images/reboot.png 40fcefb3JnT5XeKTuVF4yUMGOtuNZg tools/sv/images/right-end-highlight.jpg 40fcefb3-DuYOS7noo2W7b_0p7TOUg tools/sv/images/right-end-no-highlight.jpg @@ -449,6 +450,7 @@ 40fcefb3dgsa24WLk_BJeYQHrDLuOg tools/sv/images/seperator-right-highlight.jpg 40fcefb3FtiX4Pd2kT8wDlp8u8xRhQ tools/sv/images/seperator.jpg 41013a82sUdUqBv8EoAUJii3gsZ-4g tools/sv/images/shutdown.png +4104ffca-jPHLVOrW0n0VghEXXtKxg tools/sv/images/unpause.png 40fcefb3yMSrZvApO9ToIi-iQwnchA tools/sv/images/xen.png 41013a83z27rKvWIxAfUBMVZ1eDCDg tools/sv/inc/script.js 40fcefb3zGC9XNBkSwTEobCoq8YClA tools/sv/inc/style.css diff --git a/tools/python/xen/sv/DomInfo.py b/tools/python/xen/sv/DomInfo.py index a718871fd5..7e23ab792d 100755 --- a/tools/python/xen/sv/DomInfo.py +++ b/tools/python/xen/sv/DomInfo.py @@ -26,6 +26,9 @@ class DomInfo( GenTabbed ): self.dom = dom[0] GenTabbed.write_BODY( self, request ) + + def write_MENU( self, request ): + pass class DomGeneralTab( CompositeTab ): def __init__( self ): @@ -86,15 +89,37 @@ class DomSXPTab( PreTab ): class DomActionTab( ActionTab ): def __init__( self ): - ActionTab.__init__( self, { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ), - "reboot" : ( "Reboot the Domain", "reboot.png" ) } ) + actions = { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ), + "reboot" : ( "Reboot the Domain", "reboot.png" ), + "pause" : ( "Pause the Domain", "pause.png" ), + "unpause" : ( "Unpause the Domain", "unpause.png" ) } + ActionTab.__init__( self, actions ) def op_shutdown( self, request ): - print ">DomShutDown" + dom = getVar( 'dom', request ) + if not dom is None: + print ">DomShutDown %s" % dom #server.xend_node_shutdown() def op_reboot( self, request ): - print ">DomReboot" + dom = getVar( 'dom', request ) + if not dom is None: + print ">DomReboot %s" % dom #server.xend_node_reboot() + def op_pause( self, request ): + dom = getVar( 'dom', request ) + if not dom is None: + print ">DomPause %s" % dom + server.xend_domain_pause( int( dom ) ) + + def op_unpause( self, request ): + dom = getVar( 'dom', request ) + if not dom is None: + print ">DomUnpause %s" % dom + server.xend_domain_unpause( int( dom ) ) + + + + diff --git a/tools/python/xen/sv/DomList.py b/tools/python/xen/sv/DomList.py index ee55957ba6..82f7cc424b 100755 --- a/tools/python/xen/sv/DomList.py +++ b/tools/python/xen/sv/DomList.py @@ -11,6 +11,9 @@ class DomList( HTMLBase ): def __init__( self, urlWriter ): HTMLBase.__init__(self) self.urlWriter = urlWriter + + def write_MENU( self, request ): + return self.write_BODY( request, head=True, long=False ) def write_BODY( self, request, head=True, long=True ): @@ -44,11 +47,9 @@ class DomList( HTMLBase ): request.write( "%s\n" % ( url, domInfoHash['name'] ) ) if long: - request.write( "%(mem)7d\n" % domInfoHash ) - request.write( "%(cpu)3d\n" % domInfoHash ) + request.write( "%(memory)5s\n" % domInfoHash ) + request.write( "%(cpu)2s\n" % domInfoHash ) request.write( "%(state)5s\n" % domInfoHash ) - if long: - request.write( "%(cpu_time)7.1f\n" % domInfoHash ) def write_DOMAIN_HEAD( self, request, long=True ): request.write( "Domain\n" ) @@ -57,6 +58,4 @@ class DomList( HTMLBase ): request.write( "Memory / Mb\n" ) request.write( "CPU\n" ) request.write( "State\n" ) - if long: - request.write( "CPU time / s\n" ) diff --git a/tools/python/xen/sv/Main.py b/tools/python/xen/sv/Main.py index 50712c7710..9de097a1d4 100755 --- a/tools/python/xen/sv/Main.py +++ b/tools/python/xen/sv/Main.py @@ -38,14 +38,13 @@ class Main( HTMLBase ): request.write( "  " ) request.write( " " ) request.write( " " ) - request.write( " " ) + request.write( " " ) + request.write( " ") request.write( " " ) request.write( "
" ) - request.write( "
" ) + request.write( "

SV Web Interface
(C) Tom Wilkie 2004

" ) for (modName, (modTitle, module)) in self.modules.items(): - request.write( "

%s

" % (modName, modTitle)) - - DomList( self.mainUrlWriter ).write_BODY( request, True, False ) + module( self.mainUrlWriter ).write_MENU( request ) request.write( "
" ) diff --git a/tools/python/xen/sv/NodeInfo.py b/tools/python/xen/sv/NodeInfo.py index f13781bf1a..a3aac1d34c 100755 --- a/tools/python/xen/sv/NodeInfo.py +++ b/tools/python/xen/sv/NodeInfo.py @@ -11,6 +11,9 @@ class NodeInfo( GenTabbed ): return urlWriter( "mod=node%s" % url ) GenTabbed.__init__( self, "Node Details", newUrlWriter, [ 'General', 'Dmesg', ], [ NodeGeneralTab, NodeDmesgTab ] ) + + def write_MENU( self, request ): + request.write( "

Node details

" % self.urlWriter( '' ) ) class NodeGeneralTab( CompositeTab ): def __init__( self ): diff --git a/tools/python/xen/sv/util.py b/tools/python/xen/sv/util.py index 64503bad29..57940d9287 100755 --- a/tools/python/xen/sv/util.py +++ b/tools/python/xen/sv/util.py @@ -2,26 +2,21 @@ from xen.xend.XendClient import server from xen.xend import sxp from xen.xend import PrettyPrint +import types + def getDomInfoHash( domain ): - domInfo = server.xend_domain( int( domain ) ) - d = {} - d['dom'] = int( domain ) - d['name'] = sxp.child_value( domInfo, 'name' ) - d['mem'] = int( sxp.child_value( domInfo, 'memory' ) ) - d['cpu'] = int( sxp.child_value( domInfo, 'cpu' ) ) - d['state'] = sxp.child_value( domInfo, 'state' ) - d['cpu_time'] = float( sxp.child_value( domInfo, 'cpu_time' ) ) - if( sxp.child_value( domInfo, 'up_time' ) ): - d['up_time'] = float( sxp.child_value( domInfo, 'up_time' ) ) - if( sxp.child_value( domInfo, 'start_time' ) ): - d['start_time'] = float( sxp.child_value( domInfo, 'start_time' ) ) - return d + domInfoHash = sxp2hash( server.xend_domain( int( domain ) ) ) + domInfoHash['dom'] = int( domain ) + return domInfoHash def sxp2hash( s ): sxphash = {} for child in sxp.children( s ): - sxphash[ child[0] ] = child[1] + if child is types.ListType: + sxphash[ child[0] ] = sxp2hash( child[1] ) + else: + sxphash[ child[0] ] = child[1] return sxphash @@ -33,9 +28,19 @@ def sxp2string( sxp ): self.str = self.str + str temp = tmp() PrettyPrint.prettyprint( sxp, out=temp ) - return temp.str + return temp.str + +def getVar( var, request ): + + arg = request.args.get( var ) + + if arg is None or len(arg) != 1: + return None + else: + return arg[0] def bigTimeFormatter( time ): + time = float( time ) weeks = time // 604800 remainder = time % 604800 days = remainder // 86400 @@ -47,6 +52,7 @@ def bigTimeFormatter( time ): return "%d weeks, %d days, %s" % ( weeks, days, hms ) def smallTimeFormatter( time ): + time = float( time ) hours = time // 3600 remainder = time % 3600 mins = remainder // 60 @@ -56,12 +62,14 @@ def smallTimeFormatter( time ): def stateFormatter( state ): states = [ 'Running', 'Blocked', 'Paused', 'Shutdown', 'Crashed' ] + stateStr = "" + for i in range( len( state ) ): if state[i] != "-": - return states[ i ] + " (%s)" % state - - return state - + stateStr += "%s, " % states[ i ] + + return stateStr + " (%s)" % state + def memoryFormatter( mem ): mem = int( mem ) if mem >= 1024: @@ -71,6 +79,7 @@ def memoryFormatter( mem ): return "%7dMb" % mem def cpuFormatter( mhz ): + mhz = int( mhz ) if mhz > 1000: ghz = float( mhz ) / 1000.0 return "%4.2fGHz" % ghz diff --git a/tools/sv/Makefile b/tools/sv/Makefile index db432d18be..8a63d4ac1b 100755 --- a/tools/sv/Makefile +++ b/tools/sv/Makefile @@ -31,6 +31,8 @@ install: install -m0644 images/shutdown.png $(sv_insdir)/images install -m0644 images/reboot.png $(sv_insdir)/images + install -m0644 images/pause.png $(sv_insdir)/images + install -m0644 images/unpause.png $(sv_insdir)/images # make include folder mkdir -p $(sv_insdir)/inc diff --git a/tools/sv/images/pause.png b/tools/sv/images/pause.png new file mode 100644 index 0000000000000000000000000000000000000000..6e16daa177a47f3cf58fc0dc83bea2f2cba888c6 GIT binary patch literal 1662 zcmV-^27&pBP)VzaL`3A0 zva<3i4i1h>K=E_J!onY@xpwqyUVCptEPs#@xDf%aDPJ02qU>9334yg@lCG z0X_JD95Vm{h-8lelN%q9iamDhSkB|ek2M%*2pAa||G2uk76=LoE(RvkPo(Gt2q2O? z2K1B*&@&l8PX#m35ddTGp_i9eiiCv39%A(X1Q5|4117zkO`A3~e*XMfh+%+$ySsZX zu&|jzj9P#IBIq%ohXjEoTiM2q8!H$F0g#uMUu$@A0Vv2q3&3113F*4TN6!)F+eMg?*g)t4 znsHu9NeQJY00~`?%b&X#+m|*4-i0bkNy1lGld+Q0I;j&4-i01z-ZGPZXWyk^{Xd905M&^e%+Q~_yI6E83CrQzl) zV2m9B2p}dlHnwv>#;{3?z|{9cS64R#Ab^+@6%{|Qva;S8M)~ZEm6g>8fB*vbpn*QD z8ZH$zu$1Qp(EtGi_LzWxz-|^6mLcycVB~zz*4CB;u>k@I>@f`ujgLx7O2wZ(eH!Y1 zYqqzy2T#fa1Q2{&QA9*!9S;xBtD&0LfZeYfa&mI(V0?f8f_u!w#N+``q6yfo9+Dp8 z;^Gqa_xFDQ;{yZ`%GkY(jLc$Seq$JF17)c5HP8gRrnLzSrHo00aFdAvHm_gJ6nku^#B1x(ju`{t5&%@fBt+b zFyEbP%0BV6P7EWNBO%+u4fjmi!M?v=g{{0(N zINb-h5I~I7Y&xx9zg_@Xp&9{0Tn|`Bg?;(*2~5JTfdTLq*rU(~20${fje0IBDvD~0odE(206x2i9mk?v%K!iX07*qo IM6N<$f|-xg+W-In literal 0 HcmV?d00001 diff --git a/tools/sv/images/unpause.png b/tools/sv/images/unpause.png new file mode 100644 index 0000000000000000000000000000000000000000..c9713088147357d721c5c3ebfdcbd8c106e53a58 GIT binary patch literal 1890 zcmV-o2c7tdP)VzaL`3A0 zva<3i4i1h>K=E_J!onY@xpwqyUVCptEPs#@xDf%aDPJ02qU>9334yg@lCG z0X_JD95Vm{h-8lelN%q9iamDhSkB|ek2M%*2pAa||G2uk76=LoE(RvkPo(Gt2q2O? z2K1B*&@&l8PX#m35ddTGp_i9eiiCv39%A(X1Q5|4117zkO`A3~e*XMfh+%+$ySsZX zu&|jzj9P#IBIq%ohXjEoTiM2q8!H$F0g#uMUu$@A0Vv2q3&3113F*4n@-!$WGOZ|fB?eq*qb+RT-L8&-$tsZfW({SA-6#ft0AhmXEmvS{X;W(OVDKEUPZ$lN0Ro5#S{gc2%V2Um2kc~0Gp|hm(EtI& z1Wbkkr%#^_q-Lm*>N!w7M=j3*+rBI>U%nIo2p}e4FW3lJgNsu;BM+eG7=cw*7(f6q z0bAjEwCZAz>bcO+PzFv;PKxaXcD4Kg0*DD1ZJM;~Kat`&U>}PiDk_R%&jDNio&W*F zbp85u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